package org.structure.boot.demo.mybatisplus.controller;


import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;
import org.structure.boot.demo.mybatisplus.entity.User;
import org.structure.boot.demo.mybatisplus.service.IUserService;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author chuck
 * @since 2020-05-29
 */
@Controller
@RequestMapping("/user")
public class UserController {

    @Resource
    private IUserService iUserService;

    @GetMapping("/findUserById")
    @ResponseBody
    public User findUserById(@RequestParam("id") String id) {
        System.out.println("id = " + id);
        return iUserService.getById(id);
    }

    @PostMapping("/add")
    @ResponseBody
    public User add(@RequestBody User user) {
        iUserService.save(user);
        return user;
    }


}

